|
|
|
|
|
|
|
Many programmers ask why they need to create Property Get and Property Let procedures. They argue that its possible to simply create a Public variable that you can read and write to directly in the class. Although this is true, there are a couple of reasons why you might not want to do this. The biggest reason is that you want to control which properties are read-only, write-only, or both. Additionally, if you need to set other properties when one property is set, this can only be accomplished within a procedure. Another reason is that if you want to change the data type of a property, a procedure will let you perform the conversion, whereas a Public variable will not. One other reason is that you can always add data validation code to a Property Let procedure. If you have just a Public variable, you cant do this. |
|
|
|
 |
|
|
|
|
TIP Always use property procedures to expose properties to external routines. |
|
|
|
|
|
|
|
|
The Class Builder Utility |
|
|
|
|
|
|
|
|
The Class Builder utility is an add-in to the Visual Basic design environment. It allows you to create new classes, add properties to those classes, and then save the class information back to the Visual Basic design environment. It writes all of the necessary code for create class modules for your application. |
|
|
|
|
|
|
|
|
To use the Class Builder utility, select Add-Ins, Add-In Manager from the Visual Basic menu. Check the box located next to the Class Builder Utility option and then click the OK button. Now, under the Add-Ins menu, youll find a menu for the Class Builder utility. Click this menu item, to display the form shown in Figure 20.1. |
|
|
|
|
|
|
|
|
You can now add a new class to the project or change an existing class just by using this interface. The Class Builder utility can build default Property Get and Property Let procedures for you if you want. It also allows you to build one class based on the properties of another class. It doesnt allow inheritanceit only copies the appropriate properties and methods from the other class into the new class. |
|
|
|
|
|